package cjq.demo.thread.ch6_3;

import java.util.Date;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2016/5/4.
 */
public class Main {
    public static void main(String[] args) {
        LinkedBlockingDeque<String> list = new LinkedBlockingDeque<>(3);

        Client client = new Client(list);
        Thread thread = new Thread(client);
        thread.start();

        try{


        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                String request = list.take();
                System.out.println("Main: Request: "+request+" at "+new Date()+" Size: "+list.size());
            }
            TimeUnit.MILLISECONDS.sleep(300);
        }
        }catch(InterruptedException e){
            e.printStackTrace();
        }
        System.out.println("Main: End of the program.");
    }
}
